//
//  KFDInvestmentCommunityPostListViewModel.m
//  
//
//  Created by JIRENTIANXIANG on 6/26/15.
//
//

#import "KFDInvestmentCommunityPostListViewModel.h"
#import "KFDClient.h"

@implementation KFDInvestmentCommunityPostListViewModel

-(instancetype)init
{
    if (self=[super init]) {
        self.posts=[[NSArray alloc] init];
    }
    return self;
}

-(NSURLSessionTask*)loadPostsWithMaxCount:(NSUInteger)maxCount page:(NSUInteger)page
{
    KFDClient* client=[KFDClient sharedClient];
    return [client getInvestmentCommunityPostsWithMaxCount:maxCount page:page successHandler:^(NSArray *posts) {
//        dispatch_async(dispatch_get_main_queue(), ^{
            self.posts=posts;
            [[NSNotificationCenter defaultCenter] postNotificationName:KFDInvestmentCummunityPostsReadyNotification object:nil];
//        });
    } failureHandler:^(KFDResponseBody *response) {
        
    }];
}

@end
